package jnpf.engine.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @description: 流程事件枚举
 * @author: duanxu
 * @create: 2025-01-14 14:38
 **/
@Getter
@AllArgsConstructor
public enum FlowEventEnum {

    APPROVE("approve", "同意", "approveFuncConfig",4),

    REJECT("reject", "退回", "rejectFuncConfig",5),

    START_CANCEL("start_cancel", "发起撤回", "flowRecallFuncConfig",3),

    TIMEOUT("timeout", "超时", "overtimeFuncConfig",7),

    REMIND("remind", "提醒", "noticeFuncConfig",8),

    START("start", "发起", "initFuncConfig",1),

    END("end", "结束", "endFuncConfig",2),

    EDN_CANCEL("end_cancel", "节点撤回", "recallFuncConfig",6),

    INTERRUPT("interrupt", "终止", "cancelFuncConfig",9),

    ;

    private String code;

    private String event;

    private String key;

    private Integer status;


    public static FlowEventEnum getFlowEventEnum(String code) {
        for (FlowEventEnum flowEventEnum : FlowEventEnum.values()) {
            if (flowEventEnum.getCode().equals(code)) {
                return flowEventEnum;
            }
        }
        return null;
    }

    public static FlowEventEnum getFlowEventEnumByStatus(Integer status) {
        for (FlowEventEnum flowEventEnum : FlowEventEnum.values()) {
            if (flowEventEnum.getStatus().equals(status)) {
                return flowEventEnum;
            }
        }
        return null;
    }

}
